function createIcon(val, title){
var iconElement=document.createElement('i');
iconElement.setAttribute('class', 'fa fa-2x fa-' + val);
iconElement.setAttribute('id', val + '-' + uniqId());
iconElement.setAttribute('title', val);
if(title!=""){
iconElement.setAttribute('title', title);
}
return iconElement;
}
function createCustomIcon(val, title){
var iconElement=document.createElement('span');
jQuery(iconElement).addClass('fa-stack fa-1x');
jQuery(iconElement).attr('id', 'custom-' + val + '_' + uniqId());
jQuery(iconElement).attr('title', val);
if(title!=""){
jQuery(iconElement).attr('title', title);
}
var iconElementIcon=jQuery('');
iconElementIcon.addClass('fa-stack-2x');
jQuery(iconElement).append(iconElementIcon);
var iconElementValue=jQuery('' + val + '');
jQuery(iconElement).append(iconElementValue);
return iconElement;
}
function initIconTooltips(){
jQuery(".icon-hover").hover(function(){
var iconLeft=jQuery(this).position().left;
var iconTop=jQuery(this).position().top;
jQuery('.item-tooltip').remove();
var toolTiptextBorderColor=jQuery(this).attr("data-tooltip-border-color");
var toolTiptextBorderDisplay=jQuery(this).attr("data-tooltip-border-display");
var toolTiptextLabel=jQuery(this).attr("data-tooltip-label");
var toolTiptextLabelColor=jQuery(this).attr("data-tooltip-label-color");
var toolTiptextLabelBgo=jQuery(this).attr("data-tooltip-label-bgo");
var toolTiptextLabelBg=jQuery(this).attr("data-tooltip-label-bg");
var toolTiptextText=jQuery(this).attr("data-tooltip-text");
var toolTiptextTextColor=jQuery(this).attr("data-tooltip-text-color");
var toolTiptextTextBgo=jQuery(this).attr("data-tooltip-text-bgo");
var toolTiptextTextBg=jQuery(this).attr("data-tooltip-text-bg");
var iconTextHover=jQuery(this).attr("data-icon-text-hover");
var iconBgColor=jQuery(this).attr("data-icon-bg-color");
var iconShadow=jQuery(this).attr("data-icon-shadow");
var toolTipElem=jQuery("
");
var toolTipElemLabel=jQuery("" + toolTiptextLabel + "
");
toolTipElemLabel.css({
'background':'' + hex2rgba(toolTiptextLabelBg, toolTiptextLabelBgo) + '',
'color':'' + toolTiptextLabelColor + ''
});var toolTipElemText=jQuery("" + toolTiptextText + "
");
toolTipElemText.css({
'background':'' + hex2rgba(toolTiptextTextBg, toolTiptextTextBgo) + '',
'color':'' + toolTiptextTextColor + ''
});toolTipElem.append(toolTipElemLabel);
toolTipElem.append(toolTipElemText);
toolTipElem.css({
'position':'absolute',
'left':iconLeft + jQuery(this).width() + 10,
'top':iconTop + jQuery(this).height() + 10
});if(typeof toolTiptextBorderDisplay!=='undefined' && toolTiptextBorderDisplay==1){
toolTipElem.css({
'border':'solid 1px ' + toolTiptextBorderColor
});}
toolTipElem.insertAfter(jQuery(this));
jQuery(".item-tooltip").hide();
jQuery(".item-tooltip").fadeIn(1000);
jQuery(this).addClass('dm-icon-shadow');
jQuery(this).css({
"color":iconTextHover,
"background-color":iconBgColor,
"box-shadow":"0 0 10px " + iconShadow
});jQuery(this).find('i').css({
"color":iconTextHover
});}, function(){
var iconTextColor=jQuery(this).attr("data-icon-text-color");
var iconBgColor=jQuery(this).attr("data-icon-bg-color");
jQuery('.item-tooltip').fadeOut(1000, function(){ jQuery('.item-tooltip').remove(); })
jQuery(this).css({ "color":iconTextColor, "background-color":iconBgColor, "box-shadow":"unset" });jQuery(this).find('i').css({ "color":iconTextColor });});}
function uniqId(){
return Math.round(new Date().getTime() + (Math.random() * 100));
}
function hex2rgba(hex, opacity){
hex=hex.replace('#', '');
var r=parseInt(hex.substring(0, hex.length / 3), 16);
var g=parseInt(hex.substring(hex.length / 3, 2 * hex.length / 3), 16);
var b=parseInt(hex.substring(2 * hex.length / 3, 3 * hex.length / 3), 16);
return 'rgba(' + r + ',' + g + ',' + b + ',' + opacity / 100 + ')';
}
function createLegend(legendBg, legendBgo, legendPosition, legendBorderColor, legendBorderDisplay){
var legend=jQuery('');
if(typeof legendBorderDisplay!=='undefined' && legendBorderDisplay==1){
legend.css({
'border':'solid 1px ' + legendBorderColor
});}
legend.css({
'background':'' + hex2rgba(legendBg, legendBgo) + ''
});if(legendPosition=='left'){
legend.css({
'float':'left',
'left':'13px'
});}else{
legend.css({
'float':'right',
'right':'13px'
});}
if(legendPosition=='hide'){
legend.hide();
}
return legend;
}
function iconElementAtts(icon, iconData){
jQuery(icon).attr('data-tooltip-border-color', iconData.ttBorderColor);
jQuery(icon).attr('data-tooltip-border-display', iconData.ttBorderDisplay);
jQuery(icon).attr('data-tooltip-label', iconData.label);
jQuery(icon).attr('data-tooltip-label-color', iconData.ttLabelColor);
jQuery(icon).attr('data-tooltip-label-bg', iconData.ttLabelBg);
jQuery(icon).attr('data-tooltip-label-bgo', iconData.ttLabelBgo);
jQuery(icon).attr('data-tooltip-text', iconData.text);
jQuery(icon).attr('data-tooltip-text-color', iconData.ttTextColor);
jQuery(icon).attr('data-tooltip-text-bg', iconData.ttTextBg);
jQuery(icon).attr('data-tooltip-text-bgo', iconData.ttTextBgo);
jQuery(icon).attr('data-icon-text-color', iconData.iconTextColor);
jQuery(icon).attr('data-icon-text-hover', iconData.iconTextHover);
jQuery(icon).attr('data-icon-bg-color', iconData.iconBgColor);
jQuery(icon).attr('data-icon-shadow', iconData.iconShadow);
return icon;
}
function watchLegendMouseOver(){
jQuery(".legend-element").hover(function(){
var icon=jQuery("#" + jQuery(this).attr("data-icon-element"));
icon.mouseover();
var iconTextHover=icon.attr("data-icon-text-hover");
var iconBgColor=icon.attr("data-icon-bg-color");
var iconShadow=icon.attr("data-icon-shadow");
icon.css({
"color":iconTextHover,
"background-color":iconBgColor,
"box-shadow":"0 0 10px " + iconShadow
});icon.find('i').css({ "color":iconTextHover });}, function(){
var icon=jQuery("#" + jQuery(this).attr("data-icon-element"));
jQuery('.item-tooltip').fadeOut(1000, function(){ jQuery('.item-tooltip').remove(); });var iconTextColor=icon.attr("data-icon-text-color");
var iconBgColor=icon.attr("data-icon-bg-color");
icon.css({ "color":iconTextColor, "background-color":iconBgColor, "box-shadow":"unset" });icon.find('i').css({ "color":iconTextColor });});}
function handleIconElement(icon){
var iconElement=createIconElement(icon);
jQuery(iconElement).removeClass("fa-2x").removeClass("fa-stack-2x").removeAttr("title");
var iconElementForLegend=jQuery(iconElement).clone();
iconElementForLegend.attr("id", uniqId());
jQuery(iconElement).addClass("icon-hover").addClass("dm-icon-shadow");
var legendElement=jQuery('');
legendElement.append(iconElementForLegend).append(" " + icon.label);
icon.legend.append(legendElement);
iconElement=iconElementAtts(iconElement, icon);
iconElement=iconElementSetPos(iconElement, icon.left, icon.top, icon.imgWidth, icon.imgHeight, 5);
jQuery(icon.imgBlock).append(iconElement).append(icon.legend);
}
function createIconElement(iconData){
iconData.width=(4 * iconData.imgWidth) / 100;
var iconWrapper=document.createElement('div');
jQuery(iconWrapper).attr('id', 'icon-' + uniqId());
jQuery(iconWrapper).addClass('dm-icon');
if(iconData.icon.match("^custom-")){
var res=iconData.icon.split("custom-");
icon=res[1];
}else{
var icon=document.createElement('i');
jQuery(icon).addClass('fa fa-2x fa-' + iconData.icon);
jQuery(icon).attr('id', iconData.icon + '-' + uniqId());
jQuery(icon).attr('title', iconData.icon);
if(iconData.label!=""){
jQuery(icon).attr('title', iconData.label);
}
jQuery(icon).css({ "font-size":((iconData.width - 4) * 0.6) + "px", "color":iconData.iconTextColor });}
jQuery(iconWrapper).css({
"width":iconData.width + "px",
"background":iconData.iconBgColor,
"border":"1px solid " + iconData.iconTextColor,
"color":iconData.iconTextColor,
"height":iconData.width + "px"
});if(typeof iconData.link!=='undefined' && iconData.link!=""){
var linkedIcon=jQuery('');
linkedIcon.append(icon).append('');
icon=linkedIcon;
}
jQuery(iconWrapper).append(icon);
return iconWrapper;
}
function iconElementSetPos(icon, iconLeft, iconTop, imgWidth, imgHeight, boxPadding){
jQuery(icon).css({
'position':'absolute',
'left':parseInt(boxPadding) + (parseInt(iconLeft) * parseInt(imgWidth)) / 100,
'top':(parseInt(iconTop) * parseInt(imgHeight)) / 100
});return icon;
};